<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:93:"/www/wwwroot/jiedai.bianshenn.top/public/../application/index/view/bankcard/bankcard_ins.html";i:1553856828;}*/ ?>
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <title>添加银行卡</title>
    <link rel="stylesheet" href="/static/index/css/weui.css"/>
    <link rel="stylesheet" href="/static/index/css/example.css"/>
    <script src="/static/index/js/jquery-1.11.3.js"></script>
    <script src="/static/index/js/jquery.js"></script>
    <script src="/static/index/layer/layer.js"></script>
    <style>
        .weui-cells{
            margin-top:1.17647059em;
            background-color:#F8F8F8;
            line-height:1.47058824;
            font-size:17px;
            overflow:hidden;
            position:relative;
        }
        .register{
            font-size: 1rem;
        }
        .backg{
            background-image: url('/static/index/images/backg.png');
            background-size: 100% 200%;
            height: 100%;
        }
    </style>
</head>
<body ontouchstart class="backg">
<div style="width:90%;position:absolute;left: 50%;transform: translateX(-50%);" >
    <div class="weui-cells" style="background-color:transparent;">
        <div class="weui-cell" style="background-color:transparent;">
            <div class="weui-cell__bd">
                <input  class="weui-input" maxlength="20" style="width: 90%" type="text" name="name" id="name" placeholder="请输入银行名称">
            </div>
        </div>
    </div>
    <div class="weui-cells" style="background-color:transparent;">
        <div class="weui-cell" style="background-color:transparent;">
            <div class="weui-cell__bd">
                <input  class="weui-input" maxlength="20" style="width: 90%" type="text" name="cardnumber" id="cardnumber" placeholder="请输入卡号">
            </div>
        </div>
    </div>
    <div class="weui-cells" style="background-color:transparent;">
        <div class="weui-cell" style="background-color:transparent;">
            <div class="weui-cell__bd">
                <input  class="weui-input" maxlength="20" style="width: 90%" type="text" name="cardholder" id="cardholder" placeholder="请输入持卡人姓名">
            </div>
        </div>
    </div>
    <div class="weui-cells" style="background-color:transparent;">
        <div class="weui-cell" style="background-color:transparent;">
            <div class="weui-cell__bd">
                <input  class="weui-input" maxlength="20" style="width: 90%" type="text" name="phone" id="phone" placeholder="请输入绑定手机号">
            </div>
        </div>
    </div>
    <br/>
    <br/>
    <a class="weui-btn weui-btn_primary" style="background: #265EC4;" id="showTooltips" onclick="login()" >添加</a>
</div>
<div class="weui-tabbar">
    <a href="<?php echo url('index/index'); ?>" class="weui-tabbar__item weui-bar__item_on">
                    <span style="display: inline-block;position: relative;">
                        <img src="../../index/img/home.png" alt="" class="weui-tabbar__icon">
                    </span>
        <p class="weui-tabbar__label">首页</p>
    </a>
    <a href="<?php echo url('user/user'); ?>" class="weui-tabbar__item">
        <img src="../../index/img/user.png" alt="" class="weui-tabbar__icon">
        <p class="weui-tabbar__label">我</p>
    </a>
</div>
</body>
<script>
    function login() {
        //alert(123);
        var name = $(" input[ name='name' ] ").val();
        var phone = $(" input[ name='phone' ] ").val();
        var cardholder = $(" input[ name='cardholder' ] ").val();
        var pattern = /^([1-9]{1})(\d{14}|\d{18})$/,
            str = cardnumber = $(" input[ name='cardnumber' ] ").val().replace(/\s+/g, "");;
        var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;
        if(!myreg.test(phone)){layer.msg('手机号不正确');return false;}
        if(name == ''){layer.msg('银行名称不能为空');return false;}
        if(pattern.test(str)){layer.msg('卡号不正确');return false;}
        if(cardholder == ''){layer.msg('持卡人姓名不能为空');return false;}
        $.ajax({
            url: "bankcardadd",
            type: "POST",
            data: {"name":name,"cardnumber":cardnumber,"cardholder":cardholder,"phone":phone},
            dataType: "json",
            //success 会在成功接收到返回数据后触发
            success:function (re) {
                if(re.code == 1){
                    layer.msg('添加成功',function () {
                        location.href="<?php echo url('Bankcard/Bankcard'); ?>";
                    });
                }
                if(re.code == 2){
                    layer.msg('添加失败，请检查卡号');
                }
                if(re.code == 0){
                    layer.msg('提交为空');
                }
                if(re.code == 3){
                    layer.msg('此卡已添加');
                }
            }
        });
    }
</script>
<script src="/static/index/js/mui.min.js"></script>
<script>
    function plusReady(){
        var old_back = mui.back;
        mui.back = function() {
            //alert('不关闭')
        }
    }
    if(window.plus){
        plusReady();
    }else{
        document.addEventListener("plusready",plusReady,false);
    }
</script>
</html>